<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title>分页</title>
		<link type="text/css" rel="stylesheet" href="../<s:property value="#session.themeStyle.mainCss" default="Skin/PM/LightBlue/main.css"/>" />
		<style type="text/css">
		</style>
		<script type="text/javascript" src="<%=basePath%>js/jquery.js"></script>
		<script type="text/javascript">
			$(document).ready(function() {
				$("#selectMaxPage").val($("#rowsPage").val());
				$("#selectNowpage").val($("#page").val());
			});
			/* 改变每页显示条数时，需要自动跳转到第一页 */
			function modPageSize(obj) {
				var size = $(obj).val();
				$("#rowsPage").val(size);
				getData();
			}
			
			/* 翻页时同时修改select控件页面数 */
			function upDown(n) {
				$("#selectNowpage").val(n);
				changePageNum($("#selectNowpage")[0]);
			}
			function changePageNum(obj) {
				var page = $(obj).val();
				$("#page").val(page);
				getData();
			}
		</script>
	</head>
	<body >
		<input type="hidden" id="rowsPage" value='<s:property value="rowsPage"/>' />
		<input type="hidden" id="page" value='<s:property value="page"/>' />
	
							<s:if test="count > 0">
							页数：<s:property value="page" />/<s:property value="allPages" /> ｜
							总数：<s:property value="count" /> ｜ 当前页：
							<select id="selectNowpage" style="width: 40px" name="page" onChange="changePageNum(this)">
									<s:bean name="org.apache.struts2.util.Counter" id="counter">
										<s:param name="first" value="1" />
										<s:param name="last" value="allPages" />
										<s:iterator>
											<option value="<s:property/>" ${page==i?"selected" : ""}>
												<s:property />
											</option>
										</s:iterator>
									</s:bean>
								</select>
							｜ 每页数：
							<select id="selectMaxPage" style="width: 50px" name="rowsPage" onChange="modPageSize(this)">
									<option value="10">
										10
									</option>
									<option value="20">
										20
									</option>
									<option value="50">
										50
									</option>
									<option value="100">
										100
									</option>
								</select>
								<s:if test="page > 1">
									<a href="javascript:upDown(1)">&lt;&lt;</a>
									<a href="javascript:upDown(${page - 1})">上页</a>
								</s:if>
								<s:if test="page < allPages">
									<a href="javascript:upDown(${page+1})">下页</a>
									<a href="javascript:upDown(${allPages})">&gt;&gt;</a>
								</s:if>
							</s:if>
	</body>
</html>